package edu.tec.mty.test;

import java.util.Scanner;

import edu.tec.mty.core.connection.Connect;
import edu.tec.mty.core.modules.Logger;

public class ManualConnection extends Thread {

	private Connect connect = new Connect("localhost", 6000);
	private Logger logger = new Logger("test", "solens");
	private volatile boolean running = true;
	
	public ManualConnection() {
		this.connect.connectToServer();
		this.logger.start();
	}
	
	public void sendMessage(String message) {
		this.connect.sendMessage(message);
	}
	
	public void shutdown() {
		this.running = false;
		this.connect.close();
	}
	
	@Override
	public void run() {
		while (this.running) {
			String message = this.connect.receiveMessage();
			if (!message.equals("Error")) {
				this.logger.write(this, this.connect.receiveMessage());
			}
		}
	}
	
	public static void main(String[] args) {
		System.out.println("ManualConnection v0.1");
		Scanner scanner = new Scanner(System.in);
		
	}
	
}
